<template>
<div class="employee-management views-container">
  <div class="wlm-table">
    <div class="wlm-table-hearder-btn">
      <router-link tag="span" to="/permission/employeeManagementAdd">
        <el-button size="small" type="primary">添加员工</el-button>
      </router-link>
    </div>
    <div class="wlm-table-content">
      <el-table :ref="tableFormatData.employee.key" :data="tableFormatData.employee.tableData" @selection-change="handleSelectionChange" style="width: 100%">
        <el-table-column type="selection" width="55">
        </el-table-column>
        <el-table-column prop="date" label="员工姓名" header-align="left" align="left">
          <template slot-scope="scope">
            <span>{{scope.row.real_name}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="date" label="操作登录账号" header-align="left" align="left">
          <template slot-scope="scope">
            <span>{{scope.row.user_name}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="name" label="角色名称" header-align="left" align="left">
          <template slot-scope="scope">
            <span>{{scope.row.name}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="name" label="状态" header-align="left" align="left">
          <template slot-scope="scope">
            <el-switch :active-value="1" :inactive-value="0" @change="changeTableItem({store_user_id:scope.row.store_user_id,is_use:scope.row.is_use},tableFormatData.employee.change.is_use,{isWarning: scope.row.is_use === 0,warning:'是否关闭？',cancel:{msg:'已取消',val:{scope:scope,cancelStatus:{key:'is_use',val:0}}}})" v-model="scope.row.is_use"> </el-switch>
          </template>
        </el-table-column>
        <el-table-column prop="address" label="操作" header-align="left" align="left">
          <template slot-scope="scope">
            <div class="operation-group">
              <router-link class="wlm-text" tag="span" :to="{path:'/permission/employeeManagementAdd', query:{store_user_id:scope.row.store_user_id}}">
                <el-button type="text">编辑</el-button>
              </router-link>
              <div class="btn-line"></div>
              <el-button class="wlm-text" type="text" @click="delTableItem(scope.row.store_user_id)">删除</el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination-content flex-row flex-justify-b flex-align-c">
        <el-row class="pagination-btns">
          <el-checkbox class="check-all" :disabled="!hasTableData" true-label="1" false-label="0" v-model="tableFormatData.employee.files.checkall" @change="toggleSelection">全部</el-checkbox>
          <el-button class="right-8" :disabled="isGroup" size="mini" @click="delTableList">删除</el-button>
        </el-row>
        <el-pagination :disabled="!hasTableData" @size-change="listPageChange" @current-change="listPageChange" :current-page.sync="tableFormatData.employee.pagination.page" :page-sizes="tableFormatData.employee.pagination.pagesizes" :page-size.sync="tableFormatData.employee.pagination.list_rows" layout="total, sizes, prev, pager, next, jumper" :total="hasTableData?tableFormatData.employee.pagination.total : 0">
        </el-pagination>
      </div>
    </div>
  </div>
</div>
</template>

<script>
import {
  staffManage,
  staffDel,
  staffEditStatus
} from '@/api/setting'
import mixins from '@/mixins/mixins'
export default {
  mixins: [mixins.getters('Table')],
  name: 'ManagementPlatform',
  components: {

  },
  data() {
    return {
      tableFormatData: {
        current: 'employee',
        employee: {
          key: 'employee',
          api: {
            getList: staffManage,
            delList: staffDel
          },
          tableData: [],
          files: {
            ids: [],
            checkall: '0',
            Recycle: '1'
          },
          change: {
            is_use: {
              key: 'is_use',
              api: staffEditStatus
            }
          },
          pagination: {
            page: 1,
            list_rows: 10,
            pagesizes: [10, 20, 50],
            total: 0
          }
        }
      }
    }
  },
  methods: {

  }
}
</script>
